package com.kws.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.kws.common.core.domain.R;
import com.kws.common.log.annotation.Log;
import com.kws.common.log.enums.BusinessType;
import com.kws.system.domain.info.QueryConsultantExpertInfo;
import com.kws.system.domain.info.QueryConsultationRecordInfo;
import com.kws.system.domain.vo.CreateConsultantExpertRq;
import com.kws.system.domain.vo.UpdateConsultantExpertRq;
import com.kws.system.service.SysConsultantExpertService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <b>SysConsultantExpertController</b>
 *
 * @description: SysConsultantExpertController <br>
 * @date: 2024/11/4 16:23 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "咨询专家管理模块")
@RestController
public class SysConsultantExpertController {
    private static final Logger logger = LoggerFactory.getLogger(SysConsultantExpertController.class);

    @Autowired
    private SysConsultantExpertService sysConsultantExpertService;


    @ApiOperation("分页查询咨询专家列表")
    @GetMapping("/query/consultantExpert/page")
    public R<Page<QueryConsultantExpertInfo>> queryConsultantExpertPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                                        @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
                                                                        @RequestParam(required = false) String content){
        Page<QueryConsultantExpertInfo> pageInfo = sysConsultantExpertService.queryConsultantExpertPage(pageNum,pageSize,content);
        return R.ok(pageInfo);
    }

    @ApiOperation("新增咨询专家信息")
    @Log(title = "新增咨询专家信息", businessType = BusinessType.INSERT)
    @PostMapping("/create/consultantExpert")
    public R createConsultantExpert(CreateConsultantExpertRq rq){
        boolean status = sysConsultantExpertService.createConsultantExpert(rq);
        return R.ok(status);
    }


    @ApiOperation("根据ID查询咨询专家信息")
    @GetMapping("/query/consultantExpert/byId")
    public R<QueryConsultantExpertInfo> queryConsultantExpertById(@RequestParam Long id){
        QueryConsultantExpertInfo info = sysConsultantExpertService.queryConsultantExpertById(id);
        return R.ok(info);
    }

    @ApiOperation("根据ID修改专家信息")
    @Log(title = "修改咨询专家信息", businessType = BusinessType.UPDATE)
    @PostMapping("/update/consultantExpert")
    public R updateConsultantExpert(UpdateConsultantExpertRq rq){
        boolean status = sysConsultantExpertService.updateConsultantExpert(rq);
        return R.ok(status);
    }

    @ApiOperation("根据ID删除咨询专家信息")
    @Log(title = "删除咨询专家信息", businessType = BusinessType.DELETE)
    @GetMapping("/delete/consultantExpert/byId")
    public R deleteConsultantExpertById(@RequestParam Long id){
        boolean status = sysConsultantExpertService.deleteConsultantExpertById(id);
        return R.ok(status);
    }

    @ApiOperation("根据ID增加咨询专家咨询次数")
    @GetMapping("/update/consultantExpert/number")
    public R updateConsultantExpertNumber(@RequestParam Long id){
        boolean status = sysConsultantExpertService.updateConsultantExpertNumber(id);
        return R.ok(status);
    }

    @ApiOperation("根据专家ID查询咨询记录列表")
    @GetMapping("/query/consultationRecord/page")
    public R<Page<QueryConsultationRecordInfo>> queryConsultationRecordPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                                            @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
                                                                            @RequestParam Long expertId){
        Page<QueryConsultationRecordInfo> pageInfo = sysConsultantExpertService.queryConsultationRecordPage(pageNum,pageSize,expertId);
        return R.ok(pageInfo);
    }

}
